import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import postcss from './postcss.config.js'

export default defineConfig({
  plugins: [vue()],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "src"),
    },
  },
  css: {
    postcss,
    preprocessorOptions: {
      scss: {
        additionalData: '@use "@/styles" as *;',
        charset: false,
        api: "modern-compiler",
        silenceDeprecations: ["legacy-js-api"],
      },
    },
  },
  optimizeDeps: {
    include: ["ol-cesium", "cesium"],
  },
  build: {
    commonjsOptions: {
      include: [/ol-cesium/, /node_modules/],
    },
    chunkSizeWarningLimit: 1500,
    rollupOptions: {
      output: {
        manualChunks(id) {
          if (id.includes("node_modules")) {
            return id
              .toString()
              .split("node_modules/")[1]
              .split("/")[0]
              .toString();
          }
        },
      },
    },
  },
}); 